<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
  <head>
    <base href="<%=basePath%>">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	 
	<jsp:include page="/AdminV3/include/main.jsp"></jsp:include>

 	<script type="text/javascript">
 	
 	
 			var job = Ext.data.Record.create([]);
 	
 			Ext.onReady(function(){
 				new Ext.Window({
 					title:'添加人员',
 					width:520,
 					minWidth:520,
 					minHeight:380,
 					height:380,
 					plain:true,
 					layout:"form",
 					labelWidth:59,
 					defaultType:"textfield",
 					defaults:{anchor : '95%'},
 					items:[{
 						xtype:'panel',
 						baseCls:'x-plain',
 						style:'padding:5px',
 						layout:'column',
 						items:[{
 							columnWidth:.5,
 							layout:"form",
 							labelWidth:55,
 							defaultType:"textfield",
 							defaults:{width:160},
 							baseCls:"x-plain",
 							items:[{
 								fieldLabel:"姓名"
 							},{
 								fieldLabel:"年龄",
 								readOnly:true, 
 								value:0
 							},{
 								xtype:'datefield',
 								format:"Y-m-d",
 								value:new Date(),
 								editable:false, 
 								fieldLabel:"出生日期",
 								listeners:{
 									"blur":function(_df){
										var _age = _df.ownerCt.findByType("textfield")[1];
										_age.setValue(new Date().getFullYear()
												- _df.getValue().getFullYear());
									
 									}
 								}
 							},{
 								fieldLabel:"联系电话"
 							},{
 								fieldLabel:"手机号码"
 							},{
 								fieldLabel:"电子邮件"
 							},{
 								xtype:'combo',
 								fieldLabel:"性别",
 								mode:"local",
 								displayField:"sex",
 								editable:false,
 								triggerAction:'all',
 								valueField:'value',
 								value:"保密",
 								store:new Ext.data.SimpleStore({
 									fields:["sex","value"],
 									data:[["男","男"],["女","女"],["保密","保密"]]
 									
 								})
 							}]
 						},{
 							columnWidth:.5,
 							layout:"form",
 							labelWidth:55,
 							baseCls:"x-plain",
 							items:{
 								xtype:"textfield",
 								fieldLabel:"个人照片",
 								width:170,
 								height:177,
 								inputType:"image"
 							}
 						}]
 					},{
 						fieldLabel:"&nbsp;身份证号",
 						width:400
 					},{
 						fieldLabel:"&nbsp;具体地址",
 						width:400
 					},{
 						xtype:'panel',
 						layout:'column',
 						baseCls:'x-plain',
 						defaults:{baseCls:"x-plain"},
 						items:[{
 							columnWidth:.5,
 							layout:'form',
 							labelWidth:58,
 							items:{
 		 						xtype:'combo',
 		 						fieldLabel:"&nbsp;职位",
 		 						anchor:'100%',
 		 						mode:"local",
 								displayField:"job",
 								editable:false,
 								triggerAction:'all',
 								valueField:'value',
 								//value:"保密",
 								selectItem:null,
 								listeners:{
 									select:function(_combo,_record,_index){
 										_combo["selectItem"] = _record;
 										//alert(_record.get("job")+"-"+_record.get("value"))
 									}
 								},
 								store:new Ext.data.SimpleStore({
 									fields:["job","value"]
 									//,data:[["程序员","程序员"],["工程师","工程师"]
 									//,["总管","总管"]
 									//,["保密","保密"]]
 									
 								})
 		 					}
 						},{
 							style:"padding:0 0 0 5px;",
 							items:{
 								xtype:"button",
 								text:"添加职位",
 								handler:function(){
 									var _window = this.ownerCt.ownerCt.ownerCt;
 									
 									var _job = _window.findByType("combo")[1];
 									
 									Ext.MessageBox.prompt("请输入职位的名称", "职位名称", function(_btn,_text){
 											if(_btn == 'ok'&&_text!=''){
 												
	 											var _store = this.store;
	 											var _record = new job({
	 												job:_text,
	 												value:_text
	 											});
	 											_store.insert(0,_record);
	 											this["selectItem"] = _record;
	 											this.setValue(_text);
 											}
 									},_job);
 									
 								}
 								
 							}
 							
 						},{
 							style:"padding:0 0 0 5px;",
 							items:{
 								xtype:'button',
 								text:'修改职位',
 								handler:function(){
 									
									var _window = this.ownerCt.ownerCt.ownerCt;
 									
 									var _job = _window.findByType("combo")[1];
 									
 									if(_job["selectItem"]==null){
 										return;
 									}
 									
 									Ext.MessageBox.prompt("请输入修改后的名称",
 											"职位名称",function(_btn,_text){
 										if(_btn == 'ok'){
 											this["selectItem"].set("job",_text);
 											this["selectItem"].set("value",_text);
 											this.setValue(_text);
 										}
 										
 									},_job,false,_job.getValue());
 									
 								}
 							}
 						},{
 							style:"padding:0 0 0 5px;",
 							items:{
 								xtype:'button',
 								text:'删除职位',
 								handler:function(){

									var _window = this.ownerCt.ownerCt.ownerCt;
 									
 									var _job = _window.findByType("combo")[1];
 									if(_job["selectItem"]==null){
 										return;
 									}
 									Ext.MessageBox.confirm("系统提示", "你确认删除当前职位吗？", function(_btn){
										 		if(_btn == 'yes'){
										 			if(this.store.getCount()>0){
											 			this.store.remove(this["selectItem"]);
											 			
											 			if(this.store.getCount()>0){
											 				this.setValue(this.store.getAt(0).get("value"));
											 				this["selectItem"] = this.store.getAt(0);
											 			}else{
											 				this.setValue("");
											 				this["selectItem"] = null;
											 			}
										 			}else{
										 				this.setValue("");
										 			}
										 		}
 									}, _job);
 									
 								}
 							}
 						}]
 						
 					}],
 					showLock:false,
 					listeners:{
 						"show":function(_window){
 							if(!_window["showLock"]){
 								_window.findByType("textfield")[7].getEl().dom.src="AdminV3/images/noavatar_big.gif";
 								
 								_window["showLock"] = true;
 							}
 							
 							var _job = _window.findByType('combo')[1];
								
							var _store = _job.getStore();
							
							if(_store.getCount()>0){
								_job.setValue(_store.getAt(0).get("job"));
								_job["selectItem"] = _store.getAt(0);
							}
 						}
 					},
 					buttons:[{
 						text:"确定",
 						handler:function(){
 							alert(this.ownerCt.findByType("button")[1].text);
 						}
 					},{
 						text:"取消"
 					}]
 				}).show();
			});
 	</script>
  </head>
  <body>
       
       
			<div id="grid"></div>  
			
	
  </body>
</html>
